<UserControl x:Class="TeamProjectManager.Modules.WorkItemConfiguration.ComparisonView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:i="clr-namespace:TeamProjectManager.Common.Infrastructure;assembly=TeamProjectManager.Common"
             xmlns:w="clr-namespace:TeamProjectManager.Modules.WorkItemConfiguration"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Margin="0,5,0,0" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Label Grid.Column="0" Content="Sources" />

            <ListBox Grid.Column="1" ItemsSource="{Binding Path=ComparisonSources}" DisplayMemberPath="Description" SelectedItem="{Binding Path=SelectedComparisonSource}" SelectionMode="Single" MinHeight="70" MaxHeight="150" Margin="5,0,0,0" />

            <StackPanel Grid.Column="2" Orientation="Vertical" Margin="5,0,0,0">
                <TextBlock><Hyperlink Command="{Binding Path=AddComparisonSourceCommand}" ToolTip="Add a work item configuration to compare with">add...</Hyperlink></TextBlock>
                <TextBlock><Hyperlink Command="{Binding Path=EditSelectedComparisonSourceCommand}" ToolTip="Edit the selected work item configuration">edit</Hyperlink></TextBlock>
                <TextBlock><Hyperlink Command="{Binding Path=RemoveSelectedComparisonSourceCommand}" ToolTip="Remove the selected work item configuration">remove</Hyperlink></TextBlock>
                <TextBlock><Hyperlink Command="{Binding Path=RemoveAllComparisonSourcesCommand}" ToolTip="Remove all work item configurations">remove all</Hyperlink></TextBlock>
                <StackPanel Orientation="Horizontal">
                    <TextBlock><Hyperlink Command="{Binding Path=MoveSelectedComparisonSourceUpCommand}" ToolTip="Moves the selected work item configuration up">up</Hyperlink></TextBlock>
                    <TextBlock Margin="5,0,0,0"><Hyperlink Command="{Binding Path=MoveSelectedComparisonSourceDownCommand}" ToolTip="Moves the selected work item configuration up">down</Hyperlink></TextBlock>
                </StackPanel>
                <TextBlock><Hyperlink Command="{Binding Path=LoadComparisonSourcesCommand}" ToolTip="Load a list of sources from a saved file">load</Hyperlink></TextBlock>
                <TextBlock><Hyperlink Command="{Binding Path=SaveComparisonSourcesCommand}" ToolTip="Save the current list of sources to a file">save</Hyperlink></TextBlock>
            </StackPanel>

        </Grid>

        <Button Grid.Row="1" Content="Compare Team Projects With Sources" Command="{Binding Path=CompareCommand}" Margin="0,5,0,0" />

        <DataGrid Grid.Row="2" ItemsSource="{Binding Path=ComparisonResults}" SelectedItem="{Binding Path=SelectedComparisonResult}" x:Name="comparisonResultsDataGrid" SelectionMode="Single" MouseDoubleClick="comparisonResultsDataGrid_MouseDoubleClick" IsReadOnly="True" AutoGenerateColumns="False" Margin="0,5,0,0">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Team Project" Binding="{Binding Path=TeamProject}" />
                <DataGridTextColumn Header="Best Matching Source" Binding="{Binding Path=BestMatch.Source.Name}" />
                <DataGridTextColumn Header="Best Matching %" Binding="{Binding Path=BestMatch.PercentMatch, StringFormat='{}{0:0%}'}" />
                <DataGridTextColumn Header="Summary" Binding="{Binding Path=Summary}" />
            </DataGrid.Columns>
        </DataGrid>

        <Button Grid.Row="3" Content="View Comparison Details" Command="{Binding Path=ViewSelectedComparisonDetailsCommand}" Margin="0,5,0,0" />

    </Grid>
</UserControl>